package com.sina.weibo;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import com.sina.weibo.models.User;
import java.util.regex.Pattern;
import sudroid.android.CleanUtils;

public class RegisterActivity extends BaseActivity
  implements View.OnClickListener
{
  public static final String NICKNAME = "com.sina.weibo.RegisterActivity1.NICKNAME";
  public static final String PASSWORD = "com.sina.weibo.RegisterActivity1.PASSWORD";
  public static final String USRNAME = "com.sina.weibo.RegisterActivity1.USRNAME";
  private static final String passwordPattern = "[a-zA-Z0-9]{6,16}";
  private static final String usernameErrorPattern = "\\d{4,16}";
  private static final String usernamePattern = "[a-z0-9]{4,16}";
  private Button btnOk;
  private EditText etNick;
  private EditText etPassword;
  private EditText etPasswordConfirm;
  private EditText etUsrname;
  private boolean isMale = 0;
  private RadioGroup mRgSex;
  private AsyncTask<String[], Void, Object[]> mTask;

  private boolean isPasswordCorrect()
  {
    String str = this.etPassword.getText().toString();
    return Pattern.matches("[a-zA-Z0-9]{6,16}", str);
  }

  private boolean isPasswordWritePerfect()
  {
    String str1 = this.etPassword.getText().toString();
    String str2 = this.etPasswordConfirm.getText().toString();
    return str1.equals(str2);
  }

  private UsernameState isUsernameCorrect()
  {
    String str = this.etUsrname.getText().toString();
    UsernameState localUsernameState;
    if (Pattern.matches("[a-z0-9]{4,16}", str))
      if (Pattern.matches("\\d{4,16}", str))
        localUsernameState = UsernameState.ALL_NUMBER_ERROR;
    while (true)
    {
      return localUsernameState;
      localUsernameState = UsernameState.CORRECT;
      continue;
      localUsernameState = UsernameState.NORMAL_ERROR;
    }
  }

  private void regAction()
  {
    if (TextUtils.isEmpty(this.etUsrname.getText().toString()))
    {
      showToast(2131427590);
      boolean bool1 = this.etUsrname.requestFocus();
    }
    String str1;
    String str2;
    String str3;
    while (true)
    {
      return;
      if ((TextUtils.isEmpty(this.etPassword.getText().toString())) || (TextUtils.isEmpty(this.etPasswordConfirm.getText().toString())))
      {
        showToast(2131427591);
        this.etPasswordConfirm.setText("");
        this.etPassword.setText("");
        boolean bool2 = this.etPassword.requestFocus();
        continue;
      }
      UsernameState localUsernameState1 = isUsernameCorrect();
      UsernameState localUsernameState2 = UsernameState.NORMAL_ERROR;
      if (localUsernameState1 == localUsernameState2)
      {
        showToast(2131427587);
        boolean bool3 = this.etUsrname.requestFocus();
        continue;
      }
      UsernameState localUsernameState3 = isUsernameCorrect();
      UsernameState localUsernameState4 = UsernameState.ALL_NUMBER_ERROR;
      if (localUsernameState3 == localUsernameState4)
      {
        showToast(2131427588);
        boolean bool4 = this.etUsrname.requestFocus();
        continue;
      }
      if (!isPasswordCorrect())
      {
        showToast(2131427589);
        this.etPasswordConfirm.setText("");
        this.etPassword.setText("");
        boolean bool5 = this.etPassword.requestFocus();
        continue;
      }
      if (!isPasswordWritePerfect())
      {
        showToast(2131427592);
        this.etPasswordConfirm.setText("");
        this.etPassword.setText("");
        boolean bool6 = this.etPassword.requestFocus();
        continue;
      }
      str1 = this.etUsrname.getText().toString();
      str2 = this.etPassword.getText().toString();
      str3 = this.etNick.getText().toString();
      if ((str3 != null) && (str3.length() != 0))
        break;
      showToast(2131427677);
      this.etNick.setFocusable(1);
      this.etNick.setFocusableInTouchMode(1);
      boolean bool7 = this.etNick.requestFocus();
    }
    if (this.isMale);
    for (String str4 = "0"; ; str4 = "1")
    {
      RegTask localRegTask = new RegTask(null);
      String[] arrayOfString1 = new String[1];
      String[] arrayOfString2 = new String[4];
      arrayOfString2[0] = str1;
      arrayOfString2[1] = str2;
      arrayOfString2[2] = str3;
      arrayOfString2[3] = str4;
      arrayOfString1[0] = arrayOfString2;
      AsyncTask localAsyncTask = localRegTask.execute(arrayOfString1);
      this.mTask = localAsyncTask;
      break;
    }
  }

  private void showToast(int paramInt)
  {
    Toast localToast = Toast.makeText(this, paramInt, 0);
    localToast.setGravity(17, 0, 0);
    localToast.show();
  }

  void SetNewUserinfo(User paramUser, String paramString1, String paramString2)
  {
    StaticInfo.mUser = paramUser;
    StaticInfo.mPassword = paramString1;
    StaticInfo.mUsername = paramString2;
  }

  protected void handleTitleBarEvent(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 1:
    }
    while (true)
    {
      return;
      setResult(0);
      finish();
    }
  }

  public void onClick(View paramView)
  {
    switch (paramView.getId())
    {
    default:
      super.onClick(paramView);
    case 2131624114:
    }
    while (true)
    {
      return;
      regAction();
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setView(2130903073);
    String str1 = getString(2131427528);
    String str2 = getString(2131427415);
    setTitleBar(1, str1, str2, null);
    EditText localEditText1 = (EditText)findViewById(2131624105);
    this.etUsrname = localEditText1;
    EditText localEditText2 = (EditText)findViewById(2131623942);
    this.etPassword = localEditText2;
    EditText localEditText3 = (EditText)findViewById(2131624108);
    this.etPasswordConfirm = localEditText3;
    EditText localEditText4 = (EditText)findViewById(2131624110);
    this.etNick = localEditText4;
    Button localButton = (Button)findViewById(2131624114);
    this.btnOk = localButton;
    this.btnOk.setOnClickListener(this);
    RadioButton localRadioButton1 = (RadioButton)findViewById(2131624112);
    RadioButton localRadioButton2 = (RadioButton)findViewById(2131624113);
    RegisterActivity.1 local1 = new RegisterActivity.1(this);
    localRadioButton1.setOnClickListener(local1);
    RegisterActivity.2 local2 = new RegisterActivity.2(this);
    localRadioButton2.setOnClickListener(local2);
    if ((int)(Math.random() * 1000.0D) % 2 == 0)
      localRadioButton1.toggle();
    for (this.isMale = 1; ; this.isMale = 0)
    {
      RadioGroup localRadioGroup = (RadioGroup)findViewById(2131624001);
      this.mRgSex = localRadioGroup;
      return;
      localRadioButton2.toggle();
    }
  }

  protected void onDestroy()
  {
    boolean bool = CleanUtils.cancelTask(this.mTask);
    super.onDestroy();
  }

  class RegTask extends AsyncTask<String[], Void, Object[]>
  {
    private RegTask()
    {
    }

    protected Object[] doInBackground(String[][] paramArrayOfString)
    {
      try
      {
        String str1 = paramArrayOfString[0][0];
        String str2 = paramArrayOfString[0][1];
        String str3 = paramArrayOfString[0][2];
        String str4 = paramArrayOfString[0][3];
        arrayOfObject = new Object[3];
        User localUser = RPCHelper.getInstance(RegisterActivity.this.getApplication()).registerUsr(str1, str2, str3, str4);
        arrayOfObject[0] = localUser;
        arrayOfObject[1] = str1;
        arrayOfObject[2] = str2;
        return arrayOfObject;
      }
      catch (RPCHelper.HttpException localHttpException)
      {
        while (true)
          Object[] arrayOfObject = null;
      }
    }

    protected void onPostExecute(Object[] paramArrayOfObject)
    {
      super.onPostExecute(paramArrayOfObject);
      RegisterActivity.this.setProgressBarIndeterminateVisibility(0);
      if ((paramArrayOfObject == null) || (paramArrayOfObject.length != 3) || (paramArrayOfObject[0] == 0))
      {
        RegisterActivity.this.showToast(2131427593);
        boolean bool = RegisterActivity.this.etUsrname.requestFocus();
      }
      while (true)
      {
        return;
        RegisterActivity localRegisterActivity = RegisterActivity.this;
        User localUser = (User)paramArrayOfObject[0];
        String str1 = (String)paramArrayOfObject[2];
        String str2 = (String)paramArrayOfObject[1];
        localRegisterActivity.SetNewUserinfo(localUser, str1, str2);
        Context localContext = RegisterActivity.this.getApplicationContext();
        Intent localIntent1 = new Intent(localContext, SwitchUser.class);
        String str3 = String.valueOf((String)paramArrayOfObject[1]);
        StringBuilder localStringBuilder = new StringBuilder(str3);
        String str4 = RegisterActivity.this.getResources().getString(2131427586);
        String str5 = str4;
        Intent localIntent2 = localIntent1.putExtra("com.sina.weibo.RegisterActivity1.USRNAME", str5);
        String str6 = (String)paramArrayOfObject[2];
        Intent localIntent3 = localIntent1.putExtra("com.sina.weibo.RegisterActivity1.PASSWORD", str6);
        String str7 = ((User)paramArrayOfObject[0]).nick;
        Intent localIntent4 = localIntent1.putExtra("com.sina.weibo.RegisterActivity1.NICKNAME", str7);
        RegisterActivity.this.setResult(-1, localIntent1);
        RegisterActivity.this.finish();
      }
    }

    protected void onPreExecute()
    {
      super.onPreExecute();
      RegisterActivity.this.setProgressBarIndeterminateVisibility(1);
    }
  }

  enum UsernameState
  {
    static
    {
      ALL_NUMBER_ERROR = new UsernameState("ALL_NUMBER_ERROR", 2);
      UsernameState[] arrayOfUsernameState = new UsernameState[3];
      UsernameState localUsernameState1 = CORRECT;
      arrayOfUsernameState[0] = localUsernameState1;
      UsernameState localUsernameState2 = NORMAL_ERROR;
      arrayOfUsernameState[1] = localUsernameState2;
      UsernameState localUsernameState3 = ALL_NUMBER_ERROR;
      arrayOfUsernameState[2] = localUsernameState3;
      ENUM$VALUES = arrayOfUsernameState;
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.RegisterActivity
 * JD-Core Version:    0.6.0
 */